package org.sensmon.gui;

import javax.swing.JPanel;

import java.awt.GridBagLayout;
import javax.swing.JLabel;
import java.awt.GridBagConstraints;
import java.awt.Insets;
import java.awt.Color;
import javax.swing.border.LineBorder;
import javax.swing.border.CompoundBorder;

public class SensorPane extends JPanel {

	private static final long serialVersionUID = 1L;

	private JLabel lblValue;
	
	/**
	 * Create the panel.
	 */
	public SensorPane() {
		this("Noname");
	}
	
	public SensorPane(String sensorName) {
		setBorder(new CompoundBorder(new LineBorder(new Color(255, 255, 255)), new LineBorder(new Color(0, 0, 0), 1, true)));
		GridBagLayout gridBagLayout = new GridBagLayout();
		gridBagLayout.columnWidths = new int[]{0, 39, 0};
		gridBagLayout.rowHeights = new int[]{0, 0, 0};
		gridBagLayout.columnWeights = new double[]{0.0, 0.0, Double.MIN_VALUE};
		gridBagLayout.rowWeights = new double[]{0.0, 0.0, Double.MIN_VALUE};
		setLayout(gridBagLayout);
		
		JLabel lblSensorName = new JLabel(sensorName);
		GridBagConstraints gbc_lblSensorName = new GridBagConstraints();
		gbc_lblSensorName.fill = GridBagConstraints.HORIZONTAL;
		gbc_lblSensorName.gridwidth = 2;
		gbc_lblSensorName.insets = new Insets(0, 0, 5, 5);
		gbc_lblSensorName.gridx = 0;
		gbc_lblSensorName.gridy = 0;
		add(lblSensorName, gbc_lblSensorName);
		
		JLabel lblSensorValue = new JLabel("Sensor value:");
		GridBagConstraints gbc_lblSensorValue = new GridBagConstraints();
		gbc_lblSensorValue.insets = new Insets(0, 0, 0, 5);
		gbc_lblSensorValue.gridx = 0;
		gbc_lblSensorValue.gridy = 1;
		add(lblSensorValue, gbc_lblSensorValue);
		
		lblValue = new JLabel("Value");
		GridBagConstraints gbc_lblValue = new GridBagConstraints();
		gbc_lblValue.fill = GridBagConstraints.HORIZONTAL;
		gbc_lblValue.gridx = 1;
		gbc_lblValue.gridy = 1;
		add(lblValue, gbc_lblValue);
	}
	
	public void setValue(String value) {
		lblValue.setText(value);
	}

}
